//
//  WZFooterView.swift
//  weibo
//
//  Created by mac on 16/3/2.
//  Copyright © 2016年 mac. All rights reserved.
//

import UIKit
import SnapKit
class WZFooterView: UIView {

    var cellViewModel: WZCellViewModel?{
        didSet{
            commentsButton.setTitle(cellViewModel?.commentsCount ?? "评论", forState: UIControlState.Normal)
           
            retweetButton.setTitle(cellViewModel?.reposts_count ?? "转发", forState: UIControlState.Normal)
           
        }
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
       
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
  //    MARK:实现方法将按钮添加到付空间，并设置按钮的约束
    private func setupUI(){
        addSubview(retweetButton)
        addSubview(commentsButton)
        addSubview(goodButton)
        
        retweetButton.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(self.snp_left)
            make.top.equalTo(self.snp_top)
            make.bottom.equalTo(self.snp_bottom)
            make.width.equalTo(goodButton.snp_width)
        }
        
        
        goodButton.snp_makeConstraints { (make) -> Void in
            make.right.equalTo(self.snp_right)
            make.top.equalTo(self.snp_top)
            make.bottom.equalTo(self.snp_bottom)
            make.width.equalTo(goodButton.snp_width)
        }
        
        commentsButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(self.snp_top)
            make.bottom.equalTo(self.snp_bottom)
            make.left.equalTo(retweetButton.snp_right)
            make.right.equalTo(goodButton.snp_left)
            
        }
        
        
    }
    
    //    MARK:三个按钮的懒加载
    lazy var retweetButton: UIButton = {
        let btn = UIButton()
        btn.setImage(UIImage(named: "timeline_icon_retweet"), forState: .Normal)
        btn.setTitle("转发", forState: UIControlState.Normal)
        btn.setTitleColor(UIColor.darkGrayColor(), forState: UIControlState.Normal)
        btn.titleLabel?.font = UIFont.systemFontOfSize(11)
        return btn
    }()
    
    lazy var commentsButton: UIButton = {
        let btn = UIButton()
        btn.setImage(UIImage(named: "timeline_icon_comment"), forState: UIControlState.Normal)
        btn.setTitle("评论", forState: UIControlState.Normal)
        btn.setTitleColor(UIColor.darkGrayColor(), forState: UIControlState.Normal)
btn.titleLabel?.font = UIFont.systemFontOfSize(11)
        return btn
    }()
    lazy var goodButton: UIButton = {
        let btn = UIButton()
        btn.setImage(UIImage(named: "timeline_icon_unlike"), forState: UIControlState.Normal)
        btn.setTitle("赞", forState: UIControlState.Normal)
        btn.setTitleColor(UIColor.darkGrayColor(), forState: UIControlState.Normal)
        btn.titleLabel?.font = UIFont.systemFontOfSize(11)
        return btn
    }()
    
}
